/**
 * Created with hong.rong
 * Description:*
 * Date:2020/06/29
 */

import { isNaN, round } from 'lodash'
export * from './routes'

/**
 * 转千分符
 * @param num
 * @param precision
 * @returns {string}
 */
export function thousandSeparatorHandler(num, precision = 2) {
  if (isNaN(Number(num)) || (!num && num !== 0)) {
    return ''
  }
  return round(Number(num), precision)
    .toFixed(precision)
    .replace(/(\d)(?=(\d{3})+\.)/g, '$1,')
}
